package com.sos.widget.binding;

import androidx.databinding.BindingAdapter;

import com.sos.widget.view.flyco.tablayout.CommonTabLayout;

import java.util.List;

/**
 * @Description
 * @Author 梁浩文
 * @Date 2022/9/5 16:00
 */
public class CommonTabLayoutBinding {
    @BindingAdapter(value = {"saas_commontab_textColor",
            "saas_commontab_select_textColor",
            "saas_commontab_indicator_enable",
            "saas_commontab_indicator_color",
            "saas_commontab_datas",
            "saas_commontab_indicator_margin_hor"}, requireAll = false)
    public static void bindCommonTabLayout(CommonTabLayout view,
                                           int defaultTextColor,
                                           int selectTextColor,
                                           boolean indicatorEnable,
                                           int indicatorColor,
                                           List tabEntities,
                                           int indicatorMarginHor
    ) {
        if (view != null) {
            if (tabEntities != null && tabEntities.size() > 0) {
                view.setTabData(tabEntities);
                view.setCurrentTab(0);
                if (defaultTextColor != 0) {
                    view.setTextUnselectColor(defaultTextColor);
                }
                if (selectTextColor != 0) {
                    view.setTextSelectColor(selectTextColor);
                }
                if (indicatorEnable) {
                    view.setIndicatorHeight(0);
                }
                if (indicatorColor != 0) {
                    view.setIndicatorColor(indicatorColor);
                }
                if(indicatorMarginHor!=0){
                    view.setIndicatorMargin(indicatorMarginHor,0,indicatorMarginHor,0);
                }
            }
         /*   if (!TextUtils.isEmpty(selectImageUrl) && isGif(selectImageUrl)) {
                GlideRequest load;
                if (isGif(selectImageUrl)) {
                    load = GlideApp.with(view.getContext()).asGif();
                } else {
                    load = GlideApp.with(view.getContext()).asBitmap();
                }
                load.load(selectImageUrl)
                        .into(new SimpleTarget<Bitmap>() {
                            @Override
                            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                                view.setImageSelectBitmap(resource);
                            }
                        });
            }*/
        }
    }
}
